﻿using KnBinarySerializer.Ver;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KnBinarySerializer
{
    public  class BinaySerializer
    {
        public static FormatVer FormatVer = FormatVer.Lastest;
        public static byte[] Serialize(object obj,bool isGzip =true, FormatVer ver = FormatVer.Lastest)
        {
            using (BinarySerializeManager bianaySerializeManager = new BinarySerializeManager(ver,isGzip))
            {
                bianaySerializeManager.SerializeObject(obj);
                return bianaySerializeManager.GetSerialResult();
            }
        }

        public static T DeSerialize<T>(byte[] content)
        {
            using (BinarySerializeManager bianaySerializeManager = new BinarySerializeManager(content))
            {
                return (T)bianaySerializeManager.DeSerializeObject(typeof(T));
            }         
        }
    }
}
